package com.example.springbootdockerdemo.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @ClassName AspectTest
 * @Author Chengy
 * @Date 2021/11/22 13:48
 * @Version 1.0
 */


@Component
@Aspect  //切面注释
@Order(1)
public class AspectTest2 {


    //前置通知 value匹配规则 也就是指定拦截的切入点（方法）
    @Before(value = "execution(* com.example.springbootdockerdemo.service.UserService.eat(*))")  // execution匹配方法   whithin匹配类所有方法
    public void before1(JoinPoint joinPoint) {
        System.out.println("前置增强--门卫开门");
    }


    @After(value = "execution(* com.example.springbootdockerdemo.service.UserService.eat(*))")  // execution匹配方法   whithin匹配类所有方法
    public void after1(JoinPoint joinPoint) {
        System.out.println("后置增强--门卫关门");
    }
}
